/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package projet_maths_svn;

import java.util.LinkedList;
import java.util.List;
import java.util.Random;

/**
 *
 * @author JR
 */
public class Carte {
    List<Token> ensemble;
    Token lucky;
    
    static Random rn = new Random();
            
    public int GetNbNum()
    {
        return ensemble.size();
    }
    
    public int GetPosOf(int value)
    {
        int tmp = -1;
        for (Token i : ensemble)
        {
            if (i.equals(value))
            {
                ensemble.indexOf(i);
            }
        }
        return tmp;
    }
    
    public boolean Equals(Carte c)
    {
        if (this.GetNbNum() != c.GetNbNum())
        {
            return false;
        }
        
        boolean areEq = true;
        for (int i = 0 ; i < GetNbNum() ; i++)
        {
            if (this.ensemble.toArray()[i] != c.ensemble.toArray()[i])
            {
                areEq = false;
                break;
            }
        }
        return areEq;
    }
    
    public Carte(List<Token> aList)
    {
        ensemble = aList;
    }
    
    public Carte (int nbNum)
    {
        if (nbNum > 9)
        {
            nbNum = 9;
        }
        else if (nbNum < 5)
        {
            nbNum = 5;
        }
        
        ensemble = new LinkedList<>();
        Token tmp;
        for (int i = 0 ; i < nbNum ; i++)
        {
            do
            {
                tmp = new Token(rn.nextInt(48)+1);
            } while (ensemble.contains(tmp));
            ensemble.add(tmp);
        }
        lucky = new Token(rn.nextInt(9)+1);
    }
    
    public double GetChancesOfWinning()
    {
        return 0;
        
    }
    
    public String ToString()
    {
        String tmp = "";
        for(Token t : ensemble)
        {
            tmp += t.ToStringChance() + "\n";
        }
        tmp += lucky.ToStringLucky();
        return tmp;
    }
    
    public String ToAllString()
    {
        String tmp = "";
        for(Token t : ensemble)
        {
            tmp += t.ToStringChance()+ "\n";
        }
        tmp += lucky.ToStringLucky();
        return tmp;
    }
}
